package com.idanchuang.support.etcache;

import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Conditional;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @author yjy
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Conditional({ConditionalOnEtCacheEnabled.OnEtCacheEnabledCondition.class})
public @interface ConditionalOnEtCacheEnabled {

    class OnEtCacheEnabledCondition extends AllNestedConditions {

        OnEtCacheEnabledCondition() {
            super(ConfigurationPhase.REGISTER_BEAN);
        }

        @ConditionalOnProperty(
                name = "idanchuang.component.etcache.enable",
                havingValue = "true",
                matchIfMissing = true
        )
        static class FoundProperty {}

    }

}
